package za.um.td.util.texture;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;



public class TextureSet 
{
	private static final Logger LOG = Logger.getLogger(TextureSet.class.getName());
	
	private String id;
	private HashMap<String,Texturete>  texturetes;
	
	public final static String NODE_TEXTURESET = "textureset";
	public final static String ATRI_NAME = "name";
	
	public TextureSet(String id)
	{
		this.setId(id);
		texturetes = new HashMap<String,Texturete>();
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public HashMap<String,Texturete> getTextureteMap() {
		return texturetes;
	}
	
	public List<Texturete> getTextureteList() {
		List<Texturete> result = new ArrayList<Texturete>(texturetes.values());
		
		Collections.sort(result,new TextureteComparator());
		
		return result;
	}
	
	public Texturete getTextureteOrder(int order) {
		List<Texturete> result = getTextureteList();
		for(int i = 0; i < result.size(); i++)
		{
			Texturete tex = (Texturete)result.get(i);
			if(tex.getOrder()==order)
				return tex;
		}
		return null;
	}
	
	
	public int size()
	{
		return texturetes.size();
	}
	
	public Texturete get(String id)
	{
		return texturetes.get(id);
	}

	public void setTextureteList(HashMap<String,Texturete> texturetes) {
		this.texturetes = texturetes;
	}
	
	public void addTexturete(Texturete tex)
	{
		texturetes.put(tex.getId(), tex);
	}
	
	public void removeTexturete(Texturete tex)
	{
		texturetes.remove(tex.getId());
	}
	
	public boolean hasTexturete(Texturete tex)
	{
		return texturetes.containsKey(tex.getId());
	}	
}
